<template>
    <div class="home">
        <div class="pic-title">
            <img class="pic-title" src="@/assets/home_images/1_02.png">
        </div>
        <div class="line"></div>
        <el-menu
            :default-active="activeIndex"
            class="el-menu-demo"
            mode="horizontal"
            @select="handleSelect"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b">
            <el-menu-item index="1">首页</el-menu-item>
            <el-menu-item index="2">需求与供给拍卖实验</el-menu-item>
            <el-menu-item index="3">软件规模度量实验</el-menu-item>
            <el-menu-item index="4">财务分析实验</el-menu-item>
            <el-menu-item index="5">实验报告</el-menu-item>
        </el-menu>
        <div class="introduction">
          <div v-if="isLogin">
            欢迎！{{ name }}。
          </div>
          <div v-if="!isLogin">
            <el-button class="btn" type="primary" @click="myLogin">登录系统</el-button>
          </div>

          <div v-if="hasPriority">

          </div>
        </div>
        <div class="footer">
            上海同济大学软件工程精品课程版权所有<br>
            上海市四平路1239号  021-65982200  <br>
            沪ICP备10014176号 　沪举报中心
        </div>
    </div>



</template>


<script>
import axios from "axios";

axios.defaults.withCredentials = true

var httpUrl = '/'

export default {
  data() {
    return {
      activeIndex: '1',
      isLogin: false,
      hasPriority: false,
      uid: '',
      name: '1',
      myInfo : {}
    };
  },
  created() {
    this.getMyInfo();
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      if (key == 1) {
        this.GoIndex();
      } else if (key == 2) {
        this.GoAuction();
      } else if (key == 3) {

      } else if (key == 4) {
        this.GoFinancialAnalysis();
      } else {
        this.GoPanel();
      }

    },
    myLogin(){
      this.$router.push({path : '/login'})
    },
    getMyInfo(){
      axios.get(httpUrl + 'ur/my').then(res => {
        if (res.data.code == 200) {
          this.isLogin = true
          this.myInfo = res.data.data
          this.name = res.data.data.name
          if (this.myInfo.priority > 0) {
            this.hasPriority = true
          }
          console.log(res.data.data)
        }
      })
    },
    GoIndex() {
      this.$router.push({path: '/home', query: {id: this.projectId}})
    },
    GoAuction() {
      this.$router.push({path: '/auction', query: {id: this.projectId}})
    },
    GoExperiment2() {

    },
    GoFinancialAnalysis() {
      this.$router.push({path: '/fa', query: {id: this.projectId}})
    },
    GoPanel() {
      this.$router.push({path: '/panel', query: {id: this.projectId}})
    },
    startFa() {
      this.$router.push({path: '/dashboard', query: {id: this.projectId}})
    }
  }
}
</script>
<style scoped>
.home{
  position: relative;
  width:80%;
  left:10%;
}
</style>
<style lang="scss" scoped>
.footer {
  padding: 55px 20px;
  text-align: center;
  background: #eeeeee;
}
</style>
